const DataTypes = require("sequelize").DataTypes;
const { sequelize } = require('@core/db-hangao');

module.exports = function() {
  return sequelize.define('dict_summary', {
    id: {
      autoIncrement: true,
      type: DataTypes.INTEGER,
      allowNull: false,
      primaryKey: true
    },
    filter: {
      type: DataTypes.STRING(255),
      allowNull: true,
      defaultValue: ""
    },
    name: {
      type: DataTypes.STRING(255),
      allowNull: true
    },
    class: {
      type: DataTypes.STRING(255),
      allowNull: true
    },
    tablename: {
      type: DataTypes.STRING(255),
      allowNull: true
    },
    updated: {
      type: DataTypes.STRING(255),
      allowNull: true,
      defaultValue: "0"
    },
    alias: {
      type: DataTypes.STRING(255),
      allowNull: true
    },
    series: {
      type: DataTypes.STRING(255),
      allowNull: true
    },
    colname: {
      type: DataTypes.STRING(255),
      allowNull: true
    },
    enabled: {
      type: DataTypes.STRING(10),
      allowNull: true,
      defaultValue: "1"
    },
    sumcol: {
      type: DataTypes.STRING(255),
      allowNull: true,
      defaultValue: ""
    },
    formula: {
      type: DataTypes.STRING(255),
      allowNull: true,
      defaultValue: ""
    },
    x_buildings: {
      type: DataTypes.STRING(10),
      allowNull: true,
      defaultValue: ""
    },
    x_xiaoqu: {
      type: DataTypes.STRING(10),
      allowNull: true,
      defaultValue: ""
    },
    x_cun: {
      type: DataTypes.STRING(10),
      allowNull: true,
      defaultValue: ""
    },
    x_xiang: {
      type: DataTypes.STRING(10),
      allowNull: true,
      defaultValue: ""
    },
    x_xian: {
      type: DataTypes.STRING(10),
      allowNull: true,
      defaultValue: ""
    },
    x_shi: {
      type: DataTypes.STRING(10),
      allowNull: true,
      defaultValue: ""
    },
    x_sheng: {
      type: DataTypes.STRING(10),
      allowNull: true,
      defaultValue: ""
    },
    srctype: {
      type: DataTypes.STRING(255),
      allowNull: true,
      defaultValue: "1"
    },
    source: {
      type: DataTypes.STRING(255),
      allowNull: true
    },
    calcunit: {
      type: DataTypes.STRING(255),
      allowNull: true,
      comment: "计量单位"
    },
    zbcomment: {
      type: DataTypes.STRING(1000),
      allowNull: true,
      comment: "指标解释"
    },
    zbkoujing: {
      type: DataTypes.STRING(1000),
      allowNull: true,
      comment: "口径说明"
    },
    zbcode: {
      type: DataTypes.STRING(255),
      allowNull: true,
      comment: "指标代码"
    }
  }, {
    sequelize,
    tableName: 'dict_summary',
    schema: 'public',
    timestamps: false,
    indexes: [
      {
        name: "dict_summary_pkey",
        unique: true,
        fields: [
          { name: "id" },
        ]
      },
      {
        name: "idx_id",
        fields: [
          { name: "id" },
        ]
      },
    ]
  });
};
